<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Admin\Product;
use App\Models\Admin\Photo;
use Storage;

class ProductController extends Controller
{
    //
    public function index(){
    	
    	$data = Product::get();
      
        $this->main['data'] = $data;

    	return view('home.product.product', $this->main);

    }

     //商品详情页展示
    public function productInfo(Request $request){

		

    	$data = Product::where('id',$request->input('id'))->get();
        
        $sn = $data->toArray();
        //var_dump($sn);
        $pic = Photo::where('product_no',$sn[0]['product_no'])->get(); 
        $this->main['data'] = $data; 
        $this->main['pic'] = $pic;  

        return view('home.product.productinfo',$this->main);

    }
    //按分类显示药品
    public function pro_category (Request $request){

       
        $data = Product::where('category_id',$request->input('category_id'))->get();  
        $this->main['data'] = $data; 
       
        return view('home.product.procates', $this->main);

    }


}
